package com.gurkensalat.ebooks.ebookmarksync.aldiko;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.gurkensalat.ebooks.ebookmarksync.shared.PackageUtilities;

public class AttemptSyncActivity extends Activity
{
	// private SharedPreferences prefs = null;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		Log.i(Constants.LOG_TAG, "onCreate - AttemptSyncActivity");

		Bundle extras = getIntent().getExtras();
		String autosync_interval = "300";

		if (extras != null)
		{
			autosync_interval = extras.getString("autosync_interval");
			if (autosync_interval == null)
			{
				autosync_interval = "not set";
			}
		}

		if (isAldikoPremiumInstalled() || isAldikoStandardInstalled())
		{
			Toast toast = Toast.makeText(getBaseContext(), "Attempt Sync clicked, Aldiko present, interval " + autosync_interval, Toast.LENGTH_SHORT);
			toast.show();
		}
		else
		{
			Toast toast = Toast.makeText(getBaseContext(), "Aldiko is not present, should be sent to market", Toast.LENGTH_LONG);
			toast.show();
		}

		finish();
	}

	private boolean isAldikoPremiumInstalled()
	{
		return PackageUtilities.isPackageInstalled(Constants.ALDIKO_PREMIUM_PACKAGENAME, getPackageManager());
	}

	private boolean isAldikoStandardInstalled()
	{
		return PackageUtilities.isPackageInstalled(Constants.ALDIKO_STANDARD_PACKAGENAME, getPackageManager());
	}

}
